package com.alex.config;

import com.alex.bean.Person;
import com.alex.pojo.Address;
import com.alex.pojo.User;
import com.alex.tool.AnnotationBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;

// 该注解可以配合Bean上的注解 @ConfigurationProperties(prefix = "xxx")来一起实现: 根据springboot配置文件注入属性+注册bean
// Bean上可以没有 Component注解,因此第3方包的类也可以这样使用
//@EnableConfigurationProperties({Person.class})

@Import({AnnotationBean.class})
@ImportResource({"classpath:beans.xml"})
@Configuration(proxyBeanMethods = true)
public class MyConfig {

    @Bean
    public User user01() {
        return new User("alex", "123");
    }

    @Bean
    public User user02() {
        return new User("alex", "123", new Address("hubei", "wuhan"));
    }
}
